<?php
/**
 * Introduction:红包领取记录表 micro_shop_bonus_get_records
 */

namespace Common\Model;


use Think\Model;

class MicroShopBonusGetRecordsModel extends Model
{
    //定义数据库连接信息
    protected $connection;

    //定义表名
    protected $tableName = 'micro_shop_bonus_get_records';

    /**
     * 初始化
     */
    public function _initialize()
    {

        $this->connection = C('Databaese');

    }

    /**
     * 获取已领取的红包金额
     * @param int $memberId
     * @return float
     */
    public function getAmount($memberId)
    {
        $amount = $this->where("member_id=$memberId")->field("sum(price) as price")->find();

        return $amount['price']?$amount['price']:0;
    }

}